package android.app.betmein.activity;

import items.EntityItem;
import viewmodel.EntityGeneralInfoViewModel;
import viewmodel.EntityMembersViewModel;
import android.app.betmein.R;
import android.app.betmein.view.EntityMembersView;
import android.app.betmein.view.EntityView;
import android.framework.binding.BindableList;
import android.framework.reflaction.annotation.FillOnInit;
import android.os.Bundle;
import android.view.Menu;

import componentes.Mapper;

public class EntityActivity extends MultipleMasterPageActivity  {
	
	@FillOnInit
	private EntityItem itemEntity;
	
    @Override
    public void init(Bundle savedInstanceState) {
        EntityMembersViewModel entityMembersViewModel = new EntityMembersViewModel(this, itemEntity.getEntity());
        EntityMembersView entityMembersView = new EntityMembersView(entityMembersViewModel, this, R.layout.simple_list);
        entityMembersViewModel.setView(entityMembersView);
        BindableList<EntityItem> members = Mapper.getInstance().map(itemEntity.getEntity().getMembersList());
		entityMembersViewModel.setMembers(members);
        
        EntityGeneralInfoViewModel entityGeneralInfoViewModel = new EntityGeneralInfoViewModel(this, itemEntity.getEntity());
        EntityView entityActivityGeneralInfoTab = new EntityView(entityGeneralInfoViewModel, this, R.layout.activity_entity_generalinfo);
        entityGeneralInfoViewModel.setView(entityActivityGeneralInfoTab);
        
        addNewView(entityActivityGeneralInfoTab);
        addNewView(entityMembersView);
            
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_entity, menu);
        return true;
    }
}
